package com.gateway.video.container;

import lombok.NonNull;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class ModuleApplicationContext extends AnnotationConfigApplicationContext {
    public ModuleApplicationContext(@NonNull() ConfigurableApplicationContext parent, @NonNull()ClassLoader classLoader) {
        super(new ModuleBeanFactory(parent, classLoader));

        setClassLoader(classLoader);
        setEnvironment(parent.getEnvironment());
    }

    static class ModuleBeanFactory extends DefaultListableBeanFactory {
        public ModuleBeanFactory(@NonNull() ConfigurableApplicationContext parent, @NonNull()ClassLoader classLoader) {
            setBeanClassLoader(classLoader);
        }
    }
}
